# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# aim:    
# author: wangkaixuan
# email:  26554189525@qq.com 
# date:   2018/1/10

def consumer():
    r = ''
    while True:
        n = yield r
        if not n:
            return
        print('[CONSUMER] Consuming %s...' % n)
        r = '200 OK'

def produce(c):
    c.send(None)
    n = 0
    while n < 5:
        n = n + 1
        print('[PRODUCER] Producing %s...' % n)
        r = c.send(n)
        print('[PRODUCER] Consumer return %s...' % r)
    c.close()

c = consumer()
produce(c)